package com.itheima.tcp;

import java.io.BufferedReader;
import java.io.IOException;
import java.io.InputStream;
import java.io.InputStreamReader;
import java.net.ServerSocket;
import java.net.Socket;

/*
tcp  服务端
 */
public class FuwuClient {

    public static void main(String[] args) throws IOException {
        //创建服务端对象
        ServerSocket ss = new ServerSocket(10086);

        //接受客户端的连接 获取socket 对象
        Socket accept = ss.accept();
        //获取输入流
        InputStream is = accept.getInputStream();
        //从流读数据
     /*   int b;
        while ((b=is.read())!=-1){
            System.out.println((char)b);
        }
*/
     //把 客户端输入的数据 字节流转换成 字符流
        BufferedReader reader = new BufferedReader(new InputStreamReader(is));
        int b;
        while ((b=reader.read())!=-1){
            System.out.println((char)b);
        }

        //释放资源
        ss.close();

    }
}
